﻿using System;
using System.Collections.Generic;
using System.Linq;
using laba2.Context;
using laba2.Entity;

namespace laba2.Repository.RepositoryImpl
{
    public class Repository<T>:IRepository<T> where T:Entity.Entity
    {
        protected List<T> _list;

        public Repository(List<T> list)
        {
            //_list = list;

        }

        public void Add(T element)
        {
            _list.Add(element);
        }

        public void Remove(T element)
        {
            _list.Remove(element);
        }

        public T Get(int id)
        {
            return (from element in _list
                   where element.Id == id
                   select element).FirstOrDefault();
        }

        public bool Contains(T element)
        {
            return _list.Contains(element);
        }
    }
}
